
# 添加库文件 async_io，包含 async_io.c 和 async_io.h
add_library(async_io SHARED async_io.c)
add_library(async_io_static STATIC async_io.c)

# 设置动态库和静态库的输出名称
set_target_properties(async_io PROPERTIES OUTPUT_NAME "async_io")
set_target_properties(async_io_static PROPERTIES OUTPUT_NAME "async_io")

# 安装动态库和静态库到指定目录
install(TARGETS async_io async_io_static
    LIBRARY DESTINATION lib
    ARCHIVE DESTINATION lib
)

# 安装头文件到指定目录
install(FILES async_io.h DESTINATION include)

# 生成 Config.cmake 文件并安装
configure_file(async_ioConfig.cmake.in async_ioConfig.cmake @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/async_ioConfig.cmake
    DESTINATION lib/cmake/async_io
)

# 添加 "uninstall" 目标
add_custom_target(uninstall
    COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
)

# 生成 cmake_uninstall.cmake 文件
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in
               ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake
               IMMEDIATE @ONLY)
